package com.oj.ojbackendjudgeservice.judge.codesandbox;

import com.oj.ojbackendjudgeservice.judge.codesandbox.impl.ExampleCodeSandbox;
import com.oj.ojbackendjudgeservice.judge.codesandbox.impl.RemoteCodeSandbox;
import com.oj.ojbackendjudgeservice.judge.codesandbox.impl.ThirdPartyCodeSandbox;

public class CodeSandboxFactory {

    // todo 如果确定代码沙箱示例不会出现线程安全问题、可复用，那么可以使用单例工厂模式
    /**
     * 创建代码沙箱示例
     *
     * @param type 沙箱类型
     */
    public static CodeSandbox newInstance(String type){
        switch (type){
            case "example":
                return new ExampleCodeSandbox();
            case "remote":
                return new RemoteCodeSandbox();
            case "thirdParty":
                return new ThirdPartyCodeSandbox();
            default:
                return new ExampleCodeSandbox();
        }
    }
}
